import 'package:flutter/material.dart';

import 'notification/my_notification.dart';

class BookWidget extends StatelessWidget {
  final String buttonText;
  final String routeText;
  final String describeText;

  BookWidget({this.buttonText, this.routeText, this.describeText});
  @override
  Widget build(BuildContext context) {
    return NotificationListener<MyNotification>(
      onNotification: (notification) {
        print("上层+" + notification.msg);
        return false;
      },
      child: Container(
        child: new Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Container(
              child: Image.asset("assets/images/build.png", fit: BoxFit.fill),
              width: 149,
              height: 116,
              margin: const EdgeInsets.only(
                  left: 20, right: 10, top: 11, bottom: 11),
            ),
            Column(
              children: <Widget>[
                Container(
                  width: 160,
                  height: 38,
                  margin: EdgeInsets.only(top: 10),
                  child: Builder(builder: (context) {
                    return FlatButton(
                        color: Color(0XFFFE8E8E),
                        onPressed: () {
                          Future future =
                              Navigator.pushNamed(context, "$routeText");
                          future.then((value) {
                            print(value);
                            MyNotification(value).dispatch(context);
                          });
                        },
                        textColor: Colors.white,
                        child:
                            Text("$buttonText", style: TextStyle(fontSize: 17)),
                        shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(10)));
                  }),
                ),
                Container(
                  width: 161,
                  margin: EdgeInsets.only(top: 15),
                  child: Text(
                    "$describeText",
                    style: TextStyle(fontSize: 14, color: Color(0xff999999)),
                  ),
                ),
              ],
            ),
          ],
        ),
        color: Colors.white,
        margin: EdgeInsets.only(bottom: 5),
      ),
    );
  }
}
